package cn.sh.yhk.quartz.dns.quartz;

import cn.sh.yhk.quartz.dns.DnsPadService;
import cn.sh.yhk.service.SystemService;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
//import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @Classname Yhk
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/10/1 18:42
 * @Created by y6522
 */
@Service
@Slf4j
class AsyncIpJob {

    @Autowired
    DnsPadService dnspadService;
    @Autowired
    SystemService systemService;

    @Scheduled(cron = "0/3 * * * * ? ")
    public void runHandWare() throws IOException, TencentCloudSDKException {
        systemService.getCpuInfo();
    }

    @Scheduled(cron = "0 0 */1 * * ?")
    public void runDns() throws IOException, TencentCloudSDKException {
        Long id = dnspadService.getRecordId();
        log.info(String.valueOf(id));
        if (id != null) {
            log.info("更新了");
            dnspadService.updateIP(id);
        }

    }
}
